package com.liruo.treasureattic.common.httpmsg.result;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class BaseResponse<T>{
    public BaseResponse() {
    }

    private int code;
    /**
     * 是一个map，每个key对应一个object
     * */
    private T data;
    public static <T> BaseResponse<T> success(T data){
        return new BaseResponse<>(Errno.SUCCESS.getCode(),data);
    }

    public static BaseResponse<String> fail(Errno error, String append){
        return new BaseResponse<>(error.getCode(),  error.getMsg() + "," + append);
    }
    public static BaseResponse<String> fail(Errno error){
        return new BaseResponse<>(error.getCode(),  error.getMsg());
    }
    public static BaseResponse<String> fail(int code, String msg){
        return new BaseResponse<>(code,  msg);
    }

}
